home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / sc3x04.exe / CONNINFO.C < prev    next >
C/C++ Source or Header  |  1993-05-25  |  4KB  |  91 lines

  1. //   IMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM;
  2. //   :                                                                    :
  3. //   : module:      conninfo.c                                            :
  4. //   : abstract:    This module shows how to make 3.x system calls using  :
  5. //   :              the F2 Shell Interface for the Get Connection Info    :
  6. //   :              API, obviously it requires the NetWare Shell.         :
  7. //   :                                                                    :
  8. //   :              This call may need to be made iteratively to return   :
  9. //   :              all of the restriction information.  For simplicity,  :
  10. //   :              this example only makes the call once.                :
  11. //   :                                                                    :
  12. //   : environment: NetWare 3.x v3.11                                     :
  13. //   :              Borland C 3.1                                         :
  14. //   :                                                                    :
  15. //   :  This software is provided as is and carries no warranty           :
  16. //   :  whatsoever.  Novell disclaims and excludes any and all implied    :
  17. //   :  warranties of merchantability, title and fitness for a particular :
  18. //   :  purpose.  Novell does not warrant that the software will satisfy  :
  19. //   :  your requirements or that the software is without defect or error :
  20. //   :  or that operation of the software will be uninterrupted.  You are :
  21. //   :  using the software at your risk.  The software is not a product   :
  22. //   :  of Novell, Inc. or any of subsidiaries.                           :
  23. //   HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM<
  24. //
  25. //                         ****** N O T I C E ******
  26. //
  27. //     This API call can cause a server abend if a connection number is
  28. //     used that is greater than what the OS supports.
  29. //
  30. //     This software is considered pre-release and may be used at your own
  31. //     risk and has been provided due to the many requests of our cust-
  32. //     omers.  Support for this module will be provided at the sole
  33. //     discretion of Novell, Inc.
  34. //
  35.  
  36. #include <stdio.h>
  37. #include <string.h>
  38. #include <stdlib.h>
  39. #include <conio.h>
  40. #include <dos.h>
  41. #include <fcntl.h>
  42. #include <sys\types.h>
  43. #include <sys\stat.h>
  44.  
  45. #include "nwsys.c"
  46.  
  47. //
  48. //  First of all, we define the request and reply structures which are
  49. //  needed for the Get Connection Information API call.  These structures are
  50. //  laid out according to the System Call documentation.
  51. //
  52.  
  53. struct  REQUEST {
  54.     WORD    sflen;                 // length of the structure
  55.     BYTE    sfcode;                // the subfunction code
  56.     DWORD   connNumber;            // target connection number
  57. }Request;
  58.  
  59. struct  {
  60.     DWORD   userID;                // Connection's User ID
  61.     WORD    userType;
  62.     BYTE    userName[48];
  63.     BYTE    loginTime[7];
  64.     BYTE    reserved;
  65. }Reply;
  66.  
  67. int main()
  68. {
  69.     int retCode;
  70.  
  71. //
  72. //  Build the request buffer
  73. //
  74.     Request.sflen = (sizeof Request) ;
  75.     Request.sfcode = 0x1c;                  // subfunction code
  76.     printf("Enter connection number: ");
  77.     scanf("%ld", &(Request.connNumber));
  78.  
  79.     retCode = NWSystemCall(0x17, &Request, sizeof(Request),
  80.                                  &Reply,   sizeof(Reply));
  81.  
  82.     if (retCode != 0) {
  83.         printf("Get Connection Information call failed.  Retcode = %d\n",
  84.             retCode);
  85.         return(-1);
  86.     }
  87.     printf("User ID: 0x%lx  User Name: %s\n", DWordSwap(Reply.userID),
  88.         Reply.userName);
  89.     return(0);
  90. }
  91.